import request from '@/utils/request'
import { ObjectType, ResponseDataPromise } from 'typings/interfaces'
import * as proxy from '@/constants/proxy'
import { Pagination } from '@/components/Records/types'

export const fetchRecordsRequest = (
  pagination: Omit<Pagination, 'total'>,
  data: ObjectType
): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-electricity-charge-sub/page',
    method: 'post',
    data,
    params: pagination,
  })

export const fetchRecordsRequestList = (
  pagination: Omit<Pagination, 'total'>,
  data: ObjectType
): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-electricity-charge-sub/list',
    method: 'post',
    data,
  })
export const createRecordRequest = (data: ObjectType): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-electricity-charge-sub',
    method: 'post',
    data,
  })

export const editRecordRequest = (data: ObjectType): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-electricity-charge-sub',
    method: 'put',
    data,
  })

export const deleteRecordsRequest = (ids: string[]) =>
  request({
    url: proxy.CHECC_API_BASE_DATA + `/bd-electricity-charge-sub`,
    method: 'delete',
    data: ids,
  })

export const lockRecordRequest = (id: string, dataLock: '0' | '1') =>
  request({
    url: proxy.CHECC_API_BASE_DATA + `/bd-electricity-charge-sub/lock`,
    method: 'post',
    data: {
      id,
      dataLock,
    },
  })

export const exportRecordsRequest = (): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-electricity-charge-sub/export',
    method: 'post',
  })

export const importRecordsRequest = (): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-electricity-charge-sub/import',
    method: 'post',
  })

export const getpowerConsumptionPoint = (data: ObjectType): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-electricity-charge-sub/getpowerConsumptionPoint',
    method: 'post',
    params: data,
  })

export const getMeteringPoint = (data: ObjectType): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-electricity-charge-sub/getMeteringPoint',
    method: 'post',
    params: data,
  })

export const getJiLiangDian = (data: ObjectType): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-electricity-charge-sub/getJiLiangDian',
    method: 'post',
    params: data,
  })

export const totalFee = (data: ObjectType): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-electricity-charge-sub/total',
    method: 'post',
    data,
  })
